package com.yanqu.road.server.cmd.assistant.assistantSkin;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.assistant.AssistantSkinProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.manger.assistant.AssistantSkinMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = GameProtocol.S_CROSS_SEE_ASSISTANT, desc = "跨服来查看本服人的小助理")
public class CrossSeeAssistantCmd implements Command {
    private long originPlayerId;
    private long originServerId;
    private long seePlayerId;
    private int topNum;

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        AssistantSkinProto.CrossSeeOtherAssistantReqMsg msg = AssistantSkinProto.CrossSeeOtherAssistantReqMsg.parseFrom(packet.getBytes());
        originPlayerId = msg.getOriginPlayerId();
        originServerId = msg.getOriginServerId();
        seePlayerId = msg.getSeePlayerId();
        topNum = msg.getTopNum();
        AssistantSkinProto.CrossSeeOtherAssistantRespMsg.Builder respMsg = AssistantSkinProto.CrossSeeOtherAssistantRespMsg.newBuilder();
        respMsg.setMsg(AssistantSkinMgr.getSeeAssistantMsg(seePlayerId, topNum));
        respMsg.setOriginPlayerId(originPlayerId);
        respMsg.setOriginServerId(originServerId);
        YanQuMessage message = YanQuMessageUtils.buildMessage(CrossProtocol.C_CROSS_SEE_OTHER_ASSISTANT_RESP, respMsg);
        GamePlayerMgr.sendPacket(0, message);
    }
}
